package com.tqfframe.studydemo.myDubboRpc.provider;

import com.tqfframe.studydemo.myDubboRpc.api.UserApi;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by Tang-QiFeng on 2022/2/17
 */
public class UserApiImpl implements UserApi {

    public static Map<Integer,Object> map=new ConcurrentHashMap<>();

    @Override
    public Integer insert(String name, Integer age, Integer id) {
        System.out.println("我是服务端，我把数据添加进数据库了");
        map.put(id,name+age);
        return 1;
    }

    @Override
    public Object getUserInfo(Integer id) {
        System.out.println("我是服务端，查询id为"+id+"的数据");
        return map.get(id);
    }

    @Override
    public Object getAllUser() {
        System.out.println("我是服务端，查询所有的数据");
        return map;
    }

    @Override
    public void delete(Integer id) {
        System.out.println("我是服务端，删除id为"+id+"的数据");
        map.remove(id);
    }
}
